const app = getApp();
const baseURL = app.globalData.baseURL;

Page({
  data: {
    userName: "",
    userPassword: ""
  },
  login() {
    wx.request({
      url: `${baseURL}/user/user/login`,
      method: 'POST',
      data: {
        "userName": this.data.userName,
        "userPassword": this.data.userPassword
      },
      success: (res) => {
        if(res.data.code == 200) {
          wx.setStorageSync('token', res.data.data.access_token)
          wx.switchTab({
            url: '/pages/home/home',
          })
        }
      },
      fail: (err) => {
        console.log(err);
      }
    })
  }
})